// Copyright 2014 Quoc-Viet Nguyen. All rights reserved.
// This software may be modified and distributed under the terms
// of the BSD license. See the LICENSE file for details.

package modbus

// TCPRTUClientHandler implements Packager and Transporter interface.
type TCPRTUClientHandler struct {
	rtuPackager
	tcpTransporter
}

// NewTCPRTUClientHandler allocates a new TCPRTUClientHandler.
func NewTCPRTUClientHandler(address string) *TCPRTUClientHandler {
	h := &TCPRTUClientHandler{}
	h.Address = address
	h.Timeout = tcpTimeout
	h.IdleTimeout = tcpIdleTimeout
	return h
}

// TCPRTUClient creates TCP client with default handler and given connect string.
func TCPRTUClient(address string) Client {
	handler := NewTCPRTUClientHandler(address)
	return NewClient(handler)
}
